package com.tfswx.fljdmxyy.api;

import com.tfswx.fljdmxyy.dto.rygl.*;
import com.tfswx.fljdmxyy.query.rygl.RygnQueryParam;
import com.tfswx.fljdmxyy.query.rygl.RygnQueryResult;
import com.tfswx.fljdmxyy.query.rygl.RyxxQueryParam;
import com.tfswx.fljdmxyy.query.rygl.RyxxQueryResult;
import com.tfswx.fljdmxyy.service.RyglService;
import com.tfswx.newbie.boot.starter.page.PageParam;
import com.tfswx.newbie.boot.starter.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 人员管理
 *
 * @Author 陈文佳
 * @Date 2023/03/24
 */
@Api(tags = "人员管理")
@RequestMapping("api/zzjg")
@RestController
public class RyglController {

    @Resource
    private RyglService ryglService;

    @ApiOperation("新增人员信息")
    @PostMapping("/addRyxx")
    public RyxxAddOutputDTO addRyxx(@RequestBody @Validated RyxxAddInputDTO dto) {
        return ryglService.addRyxx(dto);
    }

    @ApiOperation("修改人员信息")
    @PostMapping("/updateRyxx")
    public RyxxUpdateOutputDTO updateRyxx(@RequestBody @Validated RyxxUpdateInputDTO dto) {
        return ryglService.updateRyxx(dto);
    }

    @ApiOperation("删除人员信息")
    @PostMapping("/deleteRyxx")
    public RyxxDeleteOutputDTO deleteRyxx(@RequestBody @Validated RyxxDeleteInputDTO dto) {
        return ryglService.deleteRyxx(dto);
    }

    @ApiOperation("查询人员信息列表")
    @PostMapping("/queryRylb")
    public List<RyxxQueryResult> queryRylb(@RequestBody @Validated RyxxQueryParam param) {
        return ryglService.queryRylb(param);
    }

    @ApiOperation("分页查询人员信息")
    @PostMapping("/queryRyxx")
    public PageResult<RyxxQueryResult> queryRyxx(@RequestBody @Validated PageParam<RyxxQueryParam> param) {
        return ryglService.queryRyxx(param);
    }

    @ApiOperation("登录")
    @PostMapping("/login")
    public LoginOutputDTO login(@RequestBody @Validated LoginInputDTO dto) {
        return ryglService.login(dto);
    }

    @ApiOperation("解锁登录")
    @PostMapping("/unlockLogin")
    public LoginOutputDTO unlockLogin(@RequestBody @Validated UnlockLoginInputDTO dto) {
        return ryglService.unlockLogin(dto);
    }

    @ApiOperation("第三方登录")
    @PostMapping("/dsfLogin")
    public LoginOutputDTO login(@RequestBody @Validated DsfLoginInputDTO dto) {
        return ryglService.dsfLogin(dto);
    }

    @ApiOperation("用户登出")
    @PostMapping("/logout")
    public void logout() {
        ryglService.logout();
    }

    @ApiOperation(value = "获取登录人信息(心跳包)")
    @PostMapping("heartBeat")
    public LoginOutputDTO heartBeat() {
        return this.ryglService.heartBeat();
    }

    @ApiOperation("查询人员功能权限")
    @PostMapping("/queryRygn")
    public List<RygnQueryResult> queryRygn(@RequestBody @Validated RygnQueryParam param) {
        return ryglService.queryRygn(param);
    }

    @ApiOperation("修改密码")
    @PostMapping("/updateDlmm")
    public Boolean updateDlmm(@RequestBody @Validated DlmmUpdateInputDTO dto) {
        return ryglService.updateDlmm(dto);
    }

    @ApiOperation("重置密码")
    @PostMapping("/resetDlmm")
    public Boolean resetDlmm(@RequestBody @Validated DlmmResetInputDTO dto) {
        return ryglService.resetDlmm(dto);
    }

    @ApiOperation("新增人员集合（批量）")
    @PostMapping("/addRylb")
    public RylbAddOutputDTO addRylb(@RequestBody @Validated RylbBatchAddInputDTO dto) {
        return ryglService.addRylb(dto);
    }
}
